﻿using B.S.InOut.Domain;
using MediatR;
using System.Threading;
using System.Threading.Tasks;

// 获取产品的请求类
public class GetProductRequest : IRequest<ProductModel>
{
    public int ProductId { get; set; }
}

// 获取产品请求的处理程序
public class GetProductHandler : IRequestHandler<GetProductRequest, ProductModel>
{
    private readonly IBaseRepository<ProductModel> _repository;

    public GetProductHandler(IBaseRepository<ProductModel> repository)
    {
        _repository = repository;
    }

    // 处理获取产品请求
    public async Task<ProductModel> Handle(GetProductRequest request, CancellationToken cancellationToken)
    {
        return await _repository.GetByIdAsync(request.ProductId);
    }
}